package com.example.chart;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import org.xclcharts.chart.BarData;
import org.xclcharts.view.BarChartView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private BarChartView chart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        chart = (BarChartView) findViewById(R.id.chart);
        List<String> labs = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            if (i % 5 == 0) {
                labs.add(i + "");
            } else {
                labs.add("");
            }
        }
        List<Double> datas = new ArrayList<>();
        for (int j = 0; j < 28; j++) {
            datas.add( Math.random());
        }
        datas.add(0d);
        datas.add(0d);

        chart.setChartLabels(labs);
        ArrayList<BarData> barDatas = new ArrayList<>();
        barDatas.add(new BarData("", datas, 0xff55DFFF));
        chart.setChartData(barDatas);
    }
}
